Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package entity;
- import java.io.Serializable;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.xml.bind.annotation.XmlRootElement;
- /**
- *
- * @author Penz
- */
- @Entity(name="Player")
- @XmlRootElement
- public class Player implements Serializable {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int playerId;
- private String username, email, password;
- // @OneToOne
- // private List<Scoreboard> Scoreboard = new ArrayList<>();
- //
- // @OneToMany
- // private List<Upgrade> upgrades = new ArrayList<>();
- public Player() {
- }
- public Player(String username, String email, String password) {
- this.username = username;
- this.email = email;
- this.password = password;
- }
- public int getPlayerid() {
- return playerId;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- }
- package repository;
- import entity.Player;
- import java.util.List;
- import javax.ejb.Stateless;
- import javax.ws.rs.Consumes;
- import javax.ws.rs.DELETE;
- import javax.ws.rs.GET;
- import javax.ws.rs.POST;
- import javax.ws.rs.PUT;
- import javax.ws.rs.Path;
- import javax.ws.rs.PathParam;
- import javax.ws.rs.Produces;
- import javax.ws.rs.core.MediaType;
- import javax.ws.rs.core.Response;
- import service.Authentication;
- /**
- *
- * @author Penz
- */
- @Stateless
- public class PlayerFacadeREST extends AbstractFacade<Player> {
- Authentication auth = new Authentication();
- public PlayerFacadeREST() {
- super(Player.class);
- }
- @POST
- @Override
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public void create(Player entity) {
- super.create(entity);
- }
- @PUT
- @Path("{id}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public void edit(@PathParam("id") Integer id, Player entity) {
- super.edit(entity);
- }
- @DELETE
- @Path("{id}")
- public void remove(@PathParam("id") Integer id) {
- super.remove(super.find(id));
- }
- @GET
- @Path("{id}")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public Player find(@PathParam("id") Integer id) {
- return super.find(id);
- }
- @GET
- @Override
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public List<Player> findAll() {
- return super.findAll();
- }
- @GET
- @Path("{from}/{to}")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public List<Player> findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
- return super.findRange(new int[]{from, to});
- }
- @GET
- @Path("count")
- @Produces(MediaType.TEXT_PLAIN)
- public String countREST() {
- return String.valueOf(super.count());
- }
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("player.register")
- public Response registerUser(Player data) {
- Response.ResponseBuilder rs = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- String tmp = (auth.encrypt(data.getPassword()));
- data.setPassword(tmp);
- try {
- this.create(data);
- rs.status(Response.Status.CREATED);
- } catch (Exception ex) {
- System.err.println(ex);
- }
- return rs.build();
- }
- @POST
- @Consumes("application/json")
- public Response loginUser() {
- Response.ResponseBuilder rs = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- try {
- } catch (Exception ex) {
- }
- return rs.build();
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
- <persistence-unit name="Dont_Quit_Squid_Backend_PU" transaction-type="JTA">
- <jta-data-source>java:app/dqs</jta-data-source>
- <class>entity.Player</class>
- <exclude-unlisted-classes>false</exclude-unlisted-classes>
- <properties>
- <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
- </properties>
- </persistence-unit>
- </persistence>
- [2017-12-08T22:40:26.183+0100] [Payara 4.1] [SCHWERWIEGEND] [] [] [tid: _ThreadID=27 _ThreadName=http-thread-pool::http-listener-1(3)] [timeMillis: 1512769226183] [levelValue: 1000] [[
- java.lang.IllegalArgumentException: Object: entity.Player@3a0233d5 is not a known Entity type.
- at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4226)
- at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:507)
- at repository.AbstractFacade.create(AbstractFacade.java:33)
- at repository.PlayerFacadeREST.create(PlayerFacadeREST.java:35)
- at repository.PlayerFacadeREST.registerUser(PlayerFacadeREST.java:87)
- at service.ApiResource.registerUser(ApiResource.java:47)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:497)
- at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
- at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
- at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
- at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
- at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
- at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
- at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
- at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
- at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
- at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
- at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
- at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
- at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
- at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
- at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
- at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
- at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
- at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
- at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
- at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
- at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
- at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
- at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1692)
- at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
- at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
- at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:654)
- at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:593)
- at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
- at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
- at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
- at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
- at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:483)
- at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
- at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
- at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
- at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
- at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
- at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
- at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
- at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
- at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
- at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
- at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
- at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
- at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
- at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
- at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
- at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
- at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
- at java.lang.Thread.run(Thread.java:745)
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement