Java EE

17K

Solutions

9K

Contributors

Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi Team,

According to my work, I have to run 7000+ sql statements in DB2 .I have the java code of the same.But by default DB2 java can only run 1338 dynamic statements at one time.
So what I was doing that Split the input data (7000 + ) into mulitiple txt files and run program more than 7 times .Each time I have to change the input path file.

Now  instead of running program 7+ times and manually changing input path everytime,I m trying to dynamically read all the input files from that folder.
Here I am attaching a part of my program only..only the method to read input file.
Below is the code for single input file case. Assume I have files named as a.txt,b.txt,c.txt.....etc.
Text file contains data in the below format:-
----------------------
abc-465747        
dfr-756372
---------------------
Existing code which executes fine  for single input file

declared input file path
static String fileName="C:\\Users\\john\\Desktop\\policies.txt";

Open in new window


main method.
 public static void main(String[] args)
        
    {
    Pre pd = new Pre();
   
      
    pd.read_Policy_list_file(fileNames);

//other methods as a part of my work
}

Open in new window


read+policy method
public void read_Policy_list_file (String fileName)
		{
			try
			{
				BufferedReader br = new BufferedReader(new FileReader(fileName));
				try {
				    StringBuilder sb = new StringBuilder();
				    String line = br.readLine();

				    while (line != null) 
				    {
				    
				

Open in new window

0
Cloud Class® Course: Ruby Fundamentals
LVL 12
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

how utf-8, unicode are different for latin kind of characters with carrot or cap etc on them


in java are those both same?
are they different in other languages?

how html decimal code is different?
what other formats out there?
which one to use when?
which one to use to support sms on emails, sms text and different browsers, gif. pdf kind of reports etc without having to see some junk ?? kind of display issues
0
Hi,
I am writing java code to make api calls to dynamics 365...
https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/query-data-web-api
Is there any standard library that i can use to for this...
Especially with the case when in the response i get a new link :
],"@odata.nextLink":"[Organization URI]/api/data/v9.0/accounts?$select=name&$filter=contains(name,'sample')&$skiptoken=%3Ccookie%20pagenumber=%222%22%20pagingcookie=%22%253ccookie%2520page%253d%25221%2522%253e%253caccountid%2520last%253d%2522%257b695EAF89-F083-E511-80D3-00155D2A68D3%257d%2522%2520first%253d%2522%257b655EAF89-F083-E511-80D3-00155D2A68D3%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20istracking=%22False%22%20/%3E"  

Normally i would fetch the result and then check for nextLink and make an http call then again check ...
Whats the best way to do this... Is there any library..in spring framework.

Thanks
0
Hello:

I would like to know how to disable the Java security warning screen below from coming up each time run a jnlp file from my desktop.  The users complain that this is distracting because you always have to click the check box and the run button every time before the Java program starts.  To run the file you need to enable Java security HIGH and add this site to the exception site http://asycuda.customs.gov.bb/awclient/ASYCUDAWorld.jnlp which we already did but it still isn't disabled.  

What additional setting or command line parameters would disable the warning screen below?

Java Security Warning Screen
0
Hi,
I am using OAuth for Microsoft dynamics CRM.
For some strange reason its not returning accesToken when i used a refreshToken to generate a new token.
Its only retruning refreshToken and idToken. What could be the reason for that ?

Here is the screen shot of postman request -
Screen-Shot-2018-04-15-at-8.03.14-PM.pngScreen-Shot-2018-04-15-at-8.03.32-PM.png
Is this a valid OaUth protocl response ??

Thanks
0
Hi,
I was making a spring web application. Where there are lot of handlers for GET request etc.
One thing came to my mind -
Suppose I make a GET request from my chrome browser from a particular tab.
And then in the response i add some values which gets back to this same chrome tab and machine.
How exactly does that happen.
How does a response object gets linked to a particular tab in a chrome broswer.

Also is it possible to send a response object without receiving a request object from spring to a particular machine and application.
I guess it should not be possible... But what makes it impossible.
Thanks
0
Here is my code:

(assume that inFS, habitat, habitatData and i are already created/initialized, as they are initialized earlier in the code)

 

case "aquarium":

           

            habitat = inFS.nextLine();

           

            while(!habitat.contains("Aquarium")) {

               

               habitat = inFS.nextLine();

            }

           

            for (i = 1; i <= 4; i++) {

             

               habitatData = habitatData + habitat + "\n";

               habitat = inFS.nextLine();

            }

           

            habitatData = habitatData.substring(4, habitatData.length());

           

            return habitatData;

 

 

The habitats.txt file it is looking at is attached.  The two other habitats, using identical code to the above (with the exception of !habitat.contains(“Aquarium”) being “Bird” or “Penguin” instead) and they both work.

 

When I hit the “aquarium” case, I get:

 



                at java.util.Scanner.nextLine(Scanner.java:1540)

                at zooprogram.FileParser.habitatInfo(FileParser.java:246)

                at zooprogram.ZooProgramMenus.habitatMenu(ZooProgramMenus.java:173)

                at zooprogram.ZooProgramMenus.mainMenuDecision(ZooProgramMenus.java:68)

                at zooprogram.ZooProgram.main(ZooProgram.java:32)

<redacted>\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1

BUILD FAILED …
0
If i have a rest controller in spring boot how can I validate the contract that comes in if certain values of the parameters need to have certain values??? ANy code examples are appreciated!
0
I am using a Mule Enterprise Service Bus for one of our integration project.I keep  getting  WeaveExecutionException everytime I test  it.Can any one please help or point me to the right direction?Below is the error details:-

Caused by: com.mulesoft.weave.mule.exception.WeaveExecutionException: Exception while executing: 
[row,col]: [1,1]
Unexpected character '[' (code 91) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1].
	at com.mulesoft.weave.mule.exception.WeaveExecutionException$.apply(WeaveExecutionException.scala:10) ~[mule-plugin-weave-3.8.5.jar:?]
	at com.mulesoft.weave.mule.WeaveMessageProcessor.execute(WeaveMessageProcessor.scala:121) ~[mule-plugin-weave-3.8.5.jar:?]

Open in new window

0
Hi,
I want to make a Bean in context of my Junit code of a spring web application. Here is the class in the project that i want to instantiate.
This has no constructor and also uses @Value annotation. How to do it.

@Service
public class AppEnvironment {

    @Value("${app.appId}")
    private String appId;
    @Value("${app.appSecret}")
    private String appSecret;
    @Value("${app.isProd}")
    private boolean isProd;
    @Value("${app.baseUrl}")
    private String baseUrl;
    @Value("${app.botId}")
    private String botGUID;
    @Value("${app.botToken}")
    private String botToken;
    @Value("${app.iconUrl}")
    private String appIconUrl;
    private String fontColor;
    @Value("${app.notificationHostname}")
    private String reminderBotHost;

Open in new window


Thanks
0
Introducing Cloud Class® training courses
LVL 12
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Hi,
I am trying to make a Junit test for a spring project. There is a @Service class in project which has CRUDRepository objects as its member variables.
How do I get this object in My Junit context. Normally I can instantiate an Object but here there is no clear way of instantiating CRUDRepository Objects.
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = ApplicationConfig.class)
public class WorkflowTemplateTest {

    private static final ObjectMapper mapper = new ObjectMapper();

    @Autowired
    private WebApplicationContext webApplicationContext;

    @Autowired
    private ApplicationConfig applicationConfig;

    private MockMvc mockMvc;

    @Before
    public void setUp() throws Exception {
        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
    }

Open in new window


@Component
public class ApplicationConfig {
    public TemplateService getTemplateService() {
        return templateService;
    }

    public ApplicationConfig setTemplateService(TemplateService templateService) {
        this.templateService = templateService;
        return this;
    }

    @Autowired
    private TemplateService templateService;
}

Open in new window


@Service
public class TemplateService {

 
    private final WorkflowRepository workflowRepository;
    
    @Autowired
    public TemplateService(
                           WorkflowRepository workflowRepository,
                          ) {
        this.workflowRepository = workflowRepository;

    }

    public Workflow saveWorkflow(Workflow workflow) {
        return workflowRepository.save(workflow);
    }

    public Workflow getWorkflow(Integer id) {
        return workflowRepository.getWorkflowById(id);
    }

Open in new window


In the spring web application i think spring automatically initializes the workflowRepository but how will i do that when instantiating in the Junit.
What do i pass in the templateService constructor.

public interface WorkflowRepository extends CrudRepository<Workflow, Integer> {
    Workflow getWorkflowById(Integer id);

    List<Workflow> getWorkflowByWorkflowTemplate(WorkflowTemplate workflowTemplate);

    List<Workflow> getWorkflowByInitiatorOrderByCreatedOnDesc(WorkflowUser workflowUser);
}[code]

Open in new window

[/code]


Please help in getting me the Whole templateService Object.
Thanks
0
I am completely new to Java and have installed Netbeans, however when I select File then New Project it doesn't do anything.
If I click on File then open Project it does open an explorer window, but I have nothing to open and I can;t get started
0
Before Spring Boot version 2.0 and Spring 5.0 we used the following code and it works perfectly fine without any issues.

@Bean
public TomcatEmbeddedServletContainerFactory
tomcatEmbeddedServletContainerFactory() {
return new TomcatEmbeddedServletContainerFactory(){
    @Override
    protected void customizeConnector(Connector connector) {
        super.customizeConnector(connector);
        connector.setParseBodyMethods("POST,PUT,DELETE");
    }
};
}
We have upgraded to Spring boot version 2.0 and Spring 5.0

Now after upgrading to Spring boot 2.0 and Spring 5.0 we no longer find the corresponding classes.

Can somebody help me with the equivalent package or newer maven pom.xml information to fix it ?

Thanks.
0
Equivalent interceptor to PreProcessInterceptor.java (org.jboss.resteasy.spi.interception.PreProcessInterceptor ) (https://howtodoinjava.com/resteasy/jax-rs-resteasy-basic-authentication-and-authorization-tutorial/)

Trying to find a interceptor with code snippet to get the user and check whether he has permission to access the requested URL

1. Equivalent interceptor to PreProcessInterceptor.java in Spring MVC
2. Interceptor code to authorize user action
0
We have a boolean column and we defined it as isActive.

The ajax request is success. However unable to bind the variable and exception is thrown

getter name is isActive() and setter name is setIsActive()

1. We don't want to rename the column as isActive to active
2. What should be the good setter and getter when the column is isActive ?
3. What should be the good setter and getter when the column is active ?

Thanks.
0
We are iterating 100k+ records from global temporary table.below stored procedure will iterate all records from glogal temp table one by one and has to process below 3-steps.

1)to see whether product is exists or not 2)to see whether product inside the assets are having the 'category' or not. 3)to see whether the assets are having file names starts with '%pdf%' or not.

So each record has to prcoess these 3-steps and final document names will be stored in the table for the successful record.if any error comes in any of the steps then error message will be stored for that record.

Below stored procedure is taking long time to process Because its processing sequentially.

1)Is there any way to make this process faster in the stored procedure itself by doing batch process? 2)If its not possible in stored procedure then Can we change this code into Java and run this code in multi threaded mode like creating 10 threads and each thread will take 1 record concurrently and process this code.I would be happy if somebody gis some pseudo code.

which approach is going to suggest?


DECLARE
V_NODE_ID  VARCHAR2(20);
V_FILENAME VARCHAR2(100);
V_CATEGORY_COUNT INTEGER :=0;  
FINAL_FILNAME VARCHAR2(2000);
V_FINAL_ERRORMESSAGE VARCHAR2(2000);


CURSOR C1 IS
SELECT isbn FROM GT_ADD_ISBNS GT;

CURSOR C2(v_isbn in varchar2) IS
SELECT ANP.NODE_ID NODE_ID
        FROM 
        table1 ANP,
        table2 ANPP,
        table3 AN
        WHERE 
      ANP.NODE_ID=AN.ID AND
    

Open in new window

0
hi am in window 7 having this error The JDK wasn't found in directory C:\PROGRA~1\Java\jdk1.6.0_43. am not able to install or untill the java software am geting this error
error3
0
Can  anyone please  help?I am new to Ant Builds.......Ant doesnt tell me which Class file is missing.



BUILD FAILED
C:\DEV\WebappCOBRA\int\ECSBuild\build\masterbuild.xml:107: The following error occurred while executing this line:
C:\DEV\WebappCOBRA\int\ECSBuild\build\masterbuild.xml:113: The following error occurred while executing this line:
C:\DEV\WebappCOBRA\int\ECSBuild\build\masterbuild.xml:331: The following error occurred while executing this line:
java.io.FileNotFoundException: C:\DEV\WebappCOBRA\int\${target-project}\build\build.xml (The system cannot find the path specified.)....

Open in new window

0
Can we follow the below approach for Spring MVC application ??

https://stackoverflow.com/questions/48677419/using-thread-local-for-http-session

Accessing thread local for http session...Note: Each http session request will be bind to one thread...
0
Cloud Class® Course: Microsoft Exchange Server
LVL 12
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Assume we have the following code

@RestController
@RequestMapping("books", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public final class BookController {
 
  private final Map<String, Book> books = new HashMap<>();
 
  @PostMapping
  public ResponseEntity<Book> addBook(@RequestParam String title, @RequestParam String authorName) {
    String id = generateId();
    Book book = new Book(id, title, authorName);
    books.put(id, book);
    return ResponseEntity.created(URI.create("/books/" + id)).body(book);
  }
 
  @GetMapping
  public ResponseEntity<Book> getBook(@PathVariable String id) {
    Book book = books.get(id);
    if (book == null)
      return ResponseEntity.notFound().build();
 
    return ResponseEntity.ok(book);
  }
 
  @PutMapping
  public ResponseEntity<Book> updateBook(@PathVariable String id, @RequestParam String title, @RequestParam String authorName) {
    Book book = books.computeIfPresent(id, book -> book.withTitle(title).withAuthorName(authorName));
    if (book == null)
      return ResponseEntity.notFound().build();
 
    return ResponseEntity.ok(book);
  }
 
  @DeleteMapping
  public ResponseEntity<Book> removeBook(@PathVariable String id) {
    Book book = map.remove(id);
    if (book == null)
      return ResponseEntity.notFound().build();
 
    return ResponseEntity.ok(book);
  }
}


If I request DELETE /books/bbcff625a88e45fcaf28f2a535997982 …
0
Hi All,
I have created a maven project using IntelliJ IDEA.
The problem is that the dependencies are not downloading at all. My company has a proxy server which is configured in the IDE but still not downloading or updating anything.
Can u guys suggest some solution for this pls?

thx
Peter
0
why we need below kind of entries in ejb.jar.xml for MDBs

<message-driven>
			<ejb-name></ejb-name>
			<ejb-class></ejb-class>
			<messaging-type>javax.jms.MessageListener</messaging-type>
			<transaction-type>Bean</transaction-type>
			<activation-config>
				<activation-config-property>
					<activation-config-property-name>messageSelector</activation-config-property-name>
					<activation-config-property-value>Ixy 'aaa'</activation-config-property-value>
				</activation-config-property>
			</activation-config>
			<message-destination-type>javax.jms.Queue</message-destination-type>
		</message-driven>
			<message-driven>
			<ejb-name>

Open in new window

what is importance of activation-config-property-value and how that is related to XSD and incoming messages to the system through the Active MQ of IBM

Please advise.
0
Assume we have login controller where we identify user, company, session id, time etc.,

Now we want to add all these info by default in logger messages

Do we need to use MDC variable to put the key and values and log4j properties file needs to be defined as {sessionId}

MDC.put("sessionId", "121212");

Is this is the right approach or we need to do in a different way ?

Thanks.
0
How to do log4j configuration to include the HttpServlet session variables to any log by default.

Assume i have 3 variables - session id, user name, user id, company id

I want all these variables to be printed in the log with date and logger severity for any log.

How to configure it to print all the above values ?

Thanks.
0
I am trying below example

https://examples.javacodegeeks.com/enterprise-java/jms/apache-activemq-hello-world-example/


When i try to run the MEssageSender class how it ran even though there is existing Queue on ActiveMQ called JCG_QUEUE

package com.activemq.sender;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;

public class MessageSender {
	
	//URL of the JMS server. DEFAULT_BROKER_URL will just mean that JMS server is on localhost
	private static String url = ActiveMQConnection.DEFAULT_BROKER_URL;
	
	// default broker URL is : tcp://localhost:61616"
	private static String subject = "JCG_QUEUE"; // Queue Name.You can create any/many queue names as per your requirement.	
	
	public static void main(String[] args) throws JMSException {		
		// Getting JMS connection from the server and starting it
		ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
		Connection connection = connectionFactory.createConnection();
		connection.start();
		
		//Creating a non transactional session to send/receive JMS message.
		Session session = connection.createSession(false,
				Session.AUTO_ACKNOWLEDGE);	
		
		//Destination represents here our queue 'JCG_QUEUE' on the JMS server. 
		//The 

Open in new window

0

Java EE

17K

Solutions

9K

Contributors

Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.

Top Experts In
Java EE
<
Monthly
>