- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试基于JSF和hibernate做一个休息服务。数据库在 Jbossstandalone.xml 中指定。但是应该给我 MediaType.APPLICATION_JSON 的 Url 却给了我一个 Nullpointer 。de.bht.server/rest/resource/json
package de.bht.server.jax;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import com.database.Service;
import com.database.SurveyQuestion;
@Path("/resource")
public class Resource {
@Inject
private Service service;
// This method is called if Json request
@GET
@Path("/json")
@Produces(MediaType.APPLICATION_JSON)
public List<SurveyQuestion> getJson() {
System.out.println("Resource: " + service);
return service.getAllQuestions();
}
@GET
@Path("/test")
@Produces(MediaType.APPLICATION_JSON)
public List<SurveyQuestion> getTestJson() {
ArrayList<SurveyQuestion> list = new ArrayList<SurveyQuestion>();
SurveyQuestion sq = new SurveyQuestion();
sq.setFreetext(true);
sq.setId(5l);
sq.setIdx(6);
sq.setMandatory(true);
sq.setMultiplechoice(true);
sq.setSheet_id(7l);
sq.setTitle("What's app?");
for (int i = 0; i < 3; ++i)
list.add(sq);
return list;
}
}
我的休息应用程序
package de.bht.server.jax;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/rest")
public class RestApplication extends Application {
}
我的注入(inject)服务
package com.database;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@Stateless
public class Service {
@PersistenceContext
private EntityManager em;
public List<SurveyQuestion> getAllQuestions() {
System.out.println("Service: " + em);
final Query query = this.em.createNamedQuery("getWholeTable");
System.out.println("ServicePrint: " + query);
return query.getResultList();
}
}
还有我尝试绘制的 Pojo
package com.database;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@Entity
@NamedQuery(name = "getWholeTable", query = "select t from SurveyQuestion t")
@Table(name = "survey_question", schema = "tnt_test")
public class SurveyQuestion implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4571690522451469184L;
@Id
@GeneratedValue
@Column(name = "id")
private Long id;
@Column(name = "freetext")
private boolean freetext;
@Column(name = "idx")
private Integer idx;
@Column(name = "mandatory")
private boolean mandatory;
@Column(name = "multiplechoice")
private boolean multiplechoice;
@Column(name = "title")
private String title;
@Column(name = "sheet_id")
private Long sheet_id;
public SurveyQuestion() {
}
public boolean getFreetext() {
return freetext;
}
public void setFreetext(boolean freetext) {
this.freetext = freetext;
}
public Integer getIdx() {
return idx;
}
public void setIdx(Integer idx) {
this.idx = idx;
}
public boolean getMandatory() {
return mandatory;
}
public void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
public boolean getMultiplechoice() {
return multiplechoice;
}
public void setMultiplechoice(boolean multiplechoice) {
this.multiplechoice = multiplechoice;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getSheet_id() {
return sheet_id;
}
public void setSheet_id(Long sheet_id) {
this.sheet_id = sheet_id;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public String toString() {
return "SurveyQuestion ,id=" + id + ", freetext=" + freetext + ", idx="
+ idx + ", mandatory=" + mandatory + ", multiplechoice="
+ multiplechoice + ", title=" + title + ", sheet_id="
+ sheet_id;
}
}
我的堆栈跟踪
2013-12-25 13:12:53,075 INFO [org.jboss.modules] JBoss Modules version 1.1.3.GA
2013-12-25 13:12:53,310 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
2013-12-25 13:12:53,388 INFO [org.jboss.as] JBAS015899: JBoss AS 7.2.0.Alpha1-SNAPSHOT "Steropes" starting
2013-12-25 13:12:54,496 INFO [org.jboss.as.server.deployment.scanner] JBAS015003: Found de.bht.server.war in deployment directory. To trigger deployment create a file called de.bht.server.war.dodeploy
2013-12-25 13:12:54,528 INFO [org.xnio] XNIO Version 3.0.6.GA
2013-12-25 13:12:54,528 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
2013-12-25 13:12:54,528 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.6.GA
2013-12-25 13:12:54,544 INFO [org.jboss.remoting] JBoss Remoting version 3.2.8.SP1
2013-12-25 13:12:54,590 INFO [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem
2013-12-25 13:12:54,606 INFO [org.jboss.as.osgi] JBAS011906: Activating OSGi Subsystem
2013-12-25 13:12:54,606 INFO [org.jboss.as.naming] JBAS011800: Activating Naming Subsystem
2013-12-25 13:12:54,622 INFO [org.jboss.as.security] JBAS013171: Activating Security Subsystem
2013-12-25 13:12:54,668 INFO [org.jboss.as.security] JBAS013170: Current PicketBox version=4.0.13.Final
2013-12-25 13:12:54,746 INFO [org.jboss.as.webservices] JBAS015537: Activating WebServices Extension
2013-12-25 13:12:54,746 INFO [org.jboss.as.connector.logging] JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.12.Final)
2013-12-25 13:12:54,793 INFO [org.jboss.as.naming] JBAS011802: Starting Naming Service
2013-12-25 13:12:54,809 INFO [org.jboss.as.mail.extension] JBAS015400: Bound mail session [java:jboss/mail/Default]
2013-12-25 13:12:54,980 INFO [org.jboss.as.connector.subsystems.datasources] JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.2)
2013-12-25 13:12:55,043 INFO [org.jboss.ws.common.management.AbstractServerConfig] JBoss Web Services - Stack CXF Server 4.1.0.Beta2
2013-12-25 13:12:55,074 INFO [org.jboss.as.connector.subsystems.datasources] JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
2013-12-25 13:12:55,526 INFO [org.jboss.as.server.deployment.scanner] JBAS015012: Started FileSystemDeploymentService for directory C:\Development\jboss_as\standalone\deployments
2013-12-25 13:12:55,526 INFO [org.jboss.as.server.deployment] JBAS015876: Starting deployment of "de.bht.server.war"
2013-12-25 13:12:55,950 INFO [org.jboss.as.remoting] JBAS017100: Listening on 127.0.0.1:10004
2013-12-25 13:12:55,950 INFO [org.jboss.as.remoting] JBAS017100: Listening on 127.0.0.1:4452
2013-12-25 13:12:55,950 INFO [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-localhost/127.0.0.1:8085
2013-12-25 13:12:56,090 INFO [org.jboss.as.connector.subsystems.datasources] JBAS010400: Bound data source [java:jboss/datasources/WebappFrameworkDS]
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleConstructor$HandleAllArgsConstructor' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleConstructor$HandleNoArgsConstructor' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleConstructor$HandleRequiredArgsConstructor' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleLog$HandleCommonsLog' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleLog$HandleJulLog' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleLog$HandleLog4j2Log' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleLog$HandleLog4jLog' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleLog$HandleSlf4jLog' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.javac.handlers.HandleLog$HandleXSlf4jLog' for service type 'lombok.javac.JavacAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.core.Main$LicenseApp' for service type 'lombok.core.LombokApp'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.core.Main$VersionApp' for service type 'lombok.core.LombokApp'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.installer.Installer$CommandLineInstallerApp' for service type 'lombok.core.LombokApp'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.installer.Installer$CommandLineUninstallerApp' for service type 'lombok.core.LombokApp'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.installer.Installer$GraphicalInstallerApp' for service type 'lombok.core.LombokApp'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleConstructor$HandleAllArgsConstructor' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleConstructor$HandleNoArgsConstructor' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleConstructor$HandleRequiredArgsConstructor' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleLog$HandleCommonsLog' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleLog$HandleJulLog' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleLog$HandleLog4j2Log' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,665 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleLog$HandleLog4jLog' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,681 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleLog$HandleSlf4jLog' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,681 WARN [org.jboss.as.server.deployment] JBAS015893: Encountered invalid class name 'lombok.eclipse.handlers.HandleLog$HandleXSlf4jLog' for service type 'lombok.eclipse.EclipseAnnotationHandler'
2013-12-25 13:12:58,962 INFO [org.jboss.as.jpa] JBAS011401: Read persistence.xml for database
2013-12-25 13:12:59,368 INFO [org.jboss.weld.deployer] JBAS016002: Processing weld deployment de.bht.server.war
2013-12-25 13:12:59,992 INFO [org.jboss.weld.deployer] JBAS016005: Starting Services for CDI deployment: de.bht.server.war
2013-12-25 13:13:00,102 INFO [org.jboss.weld.Version] WELD-000900 1.1.16 (Final)
2013-12-25 13:13:00,165 INFO [org.jboss.as.jpa] JBAS011402: Starting Persistence Unit Service 'de.bht.server.war#database'
2013-12-25 13:13:00,321 INFO [org.hibernate.annotations.common.Version] HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2013-12-25 13:13:00,321 INFO [org.hibernate.Version] HHH000412: Hibernate Core {4.1.6.Final}
2013-12-25 13:13:00,336 INFO [org.hibernate.cfg.Environment] HHH000206: hibernate.properties not found
2013-12-25 13:13:00,336 INFO [org.hibernate.cfg.Environment] HHH000021: Bytecode provider name : javassist
2013-12-25 13:13:00,352 INFO [org.hibernate.ejb.Ejb3Configuration] HHH000204: Processing PersistenceUnitInfo [
name: database
...]
2013-12-25 13:13:00,586 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
2013-12-25 13:13:01,273 INFO [org.hibernate.dialect.Dialect] HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2013-12-25 13:13:01,273 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2013-12-25 13:13:01,289 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
2013-12-25 13:13:01,289 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] HHH000397: Using ASTQueryTranslatorFactory
2013-12-25 13:13:01,321 INFO [org.hibernate.cache.spi.UpdateTimestampsCache] HHH000250: Starting update timestamps cache at region: de.bht.server.war#database.org.hibernate.cache.spi.UpdateTimestampsCache
2013-12-25 13:13:01,321 INFO [org.infinispan.factories.GlobalComponentRegistry] ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.7.Final
2013-12-25 13:13:01,461 INFO [org.infinispan.jmx.CacheJmxRegistration] ISPN000031: MBeans were successfully registered to the platform mbean server.
2013-12-25 13:13:01,477 INFO [org.hibernate.cache.internal.StandardQueryCache] HHH000248: Starting query cache at region: de.bht.server.war#database.org.hibernate.cache.internal.StandardQueryCache
2013-12-25 13:13:01,477 INFO [org.infinispan.jmx.CacheJmxRegistration] ISPN000031: MBeans were successfully registered to the platform mbean server.
2013-12-25 13:13:01,493 INFO [org.hibernate.validator.util.Version] Hibernate Validator 4.2.0.Final
2013-12-25 13:13:01,728 INFO [org.infinispan.jmx.CacheJmxRegistration] ISPN000031: MBeans were successfully registered to the platform mbean server.
2013-12-25 13:13:01,868 INFO [org.hibernate.tool.hbm2ddl.SchemaValidator] HHH000229: Running schema validator
2013-12-25 13:13:01,868 INFO [org.hibernate.tool.hbm2ddl.SchemaValidator] HHH000102: Fetching database metadata
2013-12-25 13:13:01,899 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] HHH000261: Table found: tnt_test.survey_question
2013-12-25 13:13:01,899 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] HHH000037: Columns: [id, title, multiplechoice, idx, mandatory, sheet_id, freetext]
2013-12-25 13:13:02,040 INFO [org.jboss.weld.deployer] JBAS016008: Starting weld service for deployment de.bht.server.war
2013-12-25 13:13:02,274 INFO [org.apache.deltaspike.core.util.ClassDeactivationUtils] class: org.apache.deltaspike.core.impl.config.ConfigurationExtension activated=true
2013-12-25 13:13:02,274 INFO [org.apache.deltaspike.core.util.ClassDeactivationUtils] class: org.apache.deltaspike.core.impl.exception.control.extension.ExceptionControlExtension activated=true
2013-12-25 13:13:02,274 INFO [org.apache.deltaspike.core.util.ClassDeactivationUtils] class: org.apache.deltaspike.security.impl.extension.SecurityExtension activated=true
2013-12-25 13:13:02,289 INFO [org.apache.deltaspike.core.util.ClassDeactivationUtils] class: org.apache.deltaspike.core.impl.message.MessageBundleExtension activated=true
2013-12-25 13:13:02,289 INFO [org.apache.deltaspike.core.util.ClassDeactivationUtils] class: org.apache.deltaspike.core.impl.exclude.extension.ExcludeExtension activated=true
2013-12-25 13:13:02,289 INFO [org.apache.deltaspike.core.util.ClassDeactivationUtils] class: org.apache.deltaspike.core.impl.exclude.CustomProjectStageBeanFilter activated=true
2013-12-25 13:13:02,289 INFO [org.apache.deltaspike.core.util.ClassDeactivationUtils] class: org.apache.deltaspike.core.impl.exclude.GlobalAlternative activated=true
2013-12-25 13:13:02,289 INFO [org.apache.deltaspike.core.util.ClassDeactivationUtils] class: org.apache.deltaspike.core.impl.jmx.MBeanExtension activated=true
2013-12-25 13:13:02,368 INFO [org.apache.deltaspike.core.util.ProjectStageProducer] Computed the following DeltaSpike ProjectStage: Production
2013-12-25 13:13:03,554 INFO [org.jboss.web] JBAS018210: Register web context: /de.bht.server
2013-12-25 13:13:03,726 INFO [javax.enterprise.resource.webcontainer.jsf.config] Mojarra 2.1.13-jbossorg-1 20120919-1641 für Kontext '/de.bht.server' wird initialisiert.
2013-12-25 13:13:07,127 INFO [org.primefaces.webapp.PostConstructApplicationEventListener] Running on PrimeFaces 4.0
2013-12-25 13:13:08,002 INFO [org.jboss.as.server] JBAS018559: Deployed "de.bht.server.war"
2013-12-25 13:13:08,205 INFO [org.jboss.as] JBAS015961: Http management interface listening on http://127.0.0.1:9995/management
2013-12-25 13:13:08,205 INFO [org.jboss.as] JBAS015951: Admin console listening on http://127.0.0.1:9995
2013-12-25 13:13:08,205 INFO [org.jboss.as] JBAS015874: JBoss AS 7.2.0.Alpha1-SNAPSHOT "Steropes" started in 15582ms - Started 204 of 288 services (83 services are passive or on-demand)
2013-12-25 13:13:15,567 INFO [org.jboss.resteasy.cdi.CdiInjectorFactory] Found BeanManager at java:comp/BeanManager
2013-12-25 13:13:15,567 INFO [org.jboss.resteasy.spi.ResteasyDeployment] Deploying javax.ws.rs.core.Application: class de.bht.server.jax.RestApplication
2013-12-25 13:13:15,693 INFO [stdout] Resource: null
2013-12-25 13:13:15,709 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/de.bht.server].[de.bht.server.jax.RestApplication]] Servlet.service() for servlet de.bht.server.jax.RestApplication threw exception: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:340)
at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214)
at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:540)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:165)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at de.bht.server.jax.Resource.getJson(Resource.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525)
... 28 more
好像是
@Inject
private Service service;
资源中存在一些问题,但这是为什么呢?我很感谢任何提示。
最佳答案
您的问题的简短答案是,放置一个名为 beans.xml 的空文件。进入 WEB-INF 文件夹。
或者,您可以使用 @EJB
来注释您的服务。
请参阅此答案以获得更长的解释:Should I use @EJB or @Inject
关于java - JSF/Hibernate/Rest,为什么是空指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20772810/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!