我为在线DVD商店创建了一个EJB应用程序。我使用Netbean 7.2.1和Glassfish 3.1.2当我运行index.jsp时,它的界面启动成功,如果我单击表单提交按钮,我会收到此错误:
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
root cause
java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
在Netbean中,我得到了这个错误:
INFO: Couldn't create the bean Lookup failed for 'businessSessionBeans.UserSessionBeanRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.index_jsp._jspService(index_jsp.java:76)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
我创建了一个JavaEE企业应用程序。我有项目ejb和项目战争。因为我无法直接从ejb创建SessionBean,所以我创建了一个新的项目/Java库类,并在那里创建了实体。我将库引入ejb和war,他们识别了实体,因此我能够创建会话bean。但是我遇到了这个错误,我不知道问题所在,请参阅一些来源:
指数jsp
<%@page import="businessSessionBeans.* , java.math.*, javax.naming.*" %>
<%!
private UserSessionBeanRemote userB=null;
public void jspInit()
{
try{
InitialContext ic=new InitialContext();
userB=(UserSessionBeanRemote)ic.lookup(UserSessionBeanRemote.class.getName());
}catch(Exception e)
{System.out.println("Couldn't create the bean "+e.getMessage());}
}
public void jspDestroy()
{
userB=null;
}
%>
<% String username=(String)request.getParameter("username");
String password=(String)request.getParameter("password");
if((username!=null)&(password!=null)){
String userType=userB.userLogin(username,password);
if (userType!=null){
session.setAttribute("username",username);
session.setAttribute("password",password);
session.setAttribute("userId", userB.getUserId(username, password));
if (userType.equals("Admin"))
response.sendRedirect("admin.jsp");
else if (userType.equals("User"))
response.sendRedirect("user.jsp");
}
else{
%> <script type="text/javascript">
window.alert("User not registered");
</script>
<%}}%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
</head>
<body>
<h1>Welcome to our DVD Store!</h1>
<form method="post" action="index.jsp">
<pre>
Username: <input type="text" name="username"/><br/>
Password: <input type="password" name="password"/><br/>
<input type="submit" value="Submit"/> <input type="reset" value="Reset"/><br/>
<h3>Don't have an account? <a href="register.jsp">Sign up</a></h3>
</pre>
</form>
</body>
</html>
UserSessionBeanRemote。JAVA
public interface UserSessionBeanRemote {
public void create(java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String type);
public void edit(Entities.UserEntityBean userBean);
public void destroy(java.lang.Integer id);
public Entities.UserEntityBean find(java.lang.Object pk);
public java.util.List findAll();
public java.lang.String userLogin(java.lang.String username, java.lang.String password);
public java.lang.Integer getUserId(java.lang.String username, java.lang.String password);
}
UserSessionBean。JAVA
public class UserSessionBean implements UserSessionBeanRemote {
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
@PersistenceContext
EntityManager em;
@Override
public void create(String username,String password,String name, String type)
{
UserEntityBean userBean=new UserEntityBean();
userBean.setName(username);
userBean.setPassword(password);
userBean.setName(name);
userBean.setUserType(type);
em.persist(userBean);
}
@Override
public void edit(UserEntityBean userBean)
{
em.merge(userBean);
}
@Override
public void destroy(Integer id)
{
UserEntityBean userBean=(UserEntityBean)em.find(UserEntityBean.class, id);
em.remove(userBean);
}
@Override
public UserEntityBean find(Object pk)
{
return (UserEntityBean)em.find(UserEntityBean.class, pk);
}
@Override
public List findAll()
{
return em.createQuery("select OBJECT(o) from UserEntityBean o").getResultList();
}
@Override
public String userLogin(String username,String password)
{
String fusername,fpassword;
UserEntityBean userBean;
List userList=findAll();
Iterator it=userList.iterator();
while(it.hasNext())
{
userBean=(UserEntityBean)it.next();
fusername=userBean.getName();
fpassword=userBean.getPassword();
if(fusername.equals(username)&fpassword.equals(password))
{
return userBean.getUserType();
}
}
return null;
}
@Override
public Integer getUserId(String username,String password)
{
String fusername,fpassword;
UserEntityBean userBean;
List userList=findAll();
Iterator it=userList.iterator();
while(it.hasNext())
{
userBean=(UserEntityBean)it.next();
fusername=userBean.getName();
fpassword=userBean.getPassword();
if(fusername.equals(username)&fpassword.equals(password))
{
return userBean.getId();
}
}
return null;
}
}
最后,UserEntityBean.java
public class UserEntityBean implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
private String password;
private String userType;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return the userType
*/
public String getUserType() {
return userType;
}
/**
* @param userType the userType to set
*/
public void setUserType(String userType) {
this.userType = userType;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof UserEntityBean)) {
return false;
}
UserEntityBean other = (UserEntityBean) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "Entities.UserEntityBean[ id=" + id + " ]";
}
}
知道吗?
您应该像这样查找EJB:
userB=(UserSessionBeanRemote)ic.lookup("UserSessionBean");
并且您的代码缺少@Statless:
@Stateless(name="UserSessionBean")
public class UserSessionBean implements UserSessionBeanRemote {
我正在尝试从servlet(viewcurrentstock.java)检索一个属性到jsp(viewstock.jsp)。这里有一个例外提示:“org.apache.jasper.JasperException:java.lang.NullPointerException” 查看当前股票。JAVA viewstock.jsp 服务器日志:
我的jsp有一个代码: 这是我的servlet: 当我点击登录按钮时,我有一个错误。 提前谢谢
我在生产服务器上部署了我的项目,并得到以下错误。 这是一个实时项目,所以,在出现错误后,我用运行良好的前一个版本替换了它,但现在它也抛出了相同的错误。请告诉我有什么问题? 错误: InExpage。jsp:
在我的jsp页面中,有一些纯java代码,即scriptlet。经过很长一段时间的刷新后,它就会抛出 有时不长时间也会抛出同样的异常。JSP页面显示的是空页面。因此,用户只有一个选择是注销。为了避免这种情况,把他重定向到错误页面。怎么做?
我有两个Spring Boot服务A和B。还有一个外部服务C。这是请求路径: 网络浏览器 外部服务正在返回一个返回前端的资源。为了在A、B和C之间进行通信,我使用了Rest模板。进入Web应用程序时一切都很好,但是一旦我运行并行运行的BDD测试(9个线程),我就会在调用外部服务C时在服务B中获得NoHttp响应异常。 这是我的Rest模板配置: 我已经尝试调用但没有帮助。 让我补充一点,从服务B到
Apache Kafka:分布式消息传递系统 Apache Storm:实时消息处理 我们如何在实时数据管道中使用这两种技术来处理事件数据? 在实时数据管道方面,我觉得两者做的工作是一样的。如何在数据管道上同时使用这两种技术?